<?php

class Kd_Localize_Translator extends Kd_Collection_Array {

    public function __construct(){
        parent::__construct();
    }

    public function __($key) {
        return $this->get($key);
    }

    public function __f() {
        $args = func_get_args();
        if(is_array($args[0])){
            $args = $args[0];
        }
        $args[0] = self::__($args[0]);
        for ($i = 1; $i < count($args); $i++) {
            if ($args[$i][0] == '{' && substr($args[$i], -1) == '}') {
                $args[$i] = $this->__(substr($args[$i], 1, -1));
            }
        }
        return call_user_func_array('sprintf', $args);
    }

    public function loadFile($name, $filename){
        $this->source[$name] = Kd_Util_Yaml::parseFile($filename);
        return $this;
    }
}